package com.tinem.platform.module.starter.jpa.repository.network;

import com.tinem.platform.module.starter.jpa.entity.network.Ipv6RangeInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * @program: platform
 * @description: ${description}
 * @author: eden#can
 * @Slogan: 没有所谓失败，除非你不再尝试
 * @date: 2022-05-14 11:23
 **/
@Repository
public interface Ipv6RangeInfoRepository extends JpaRepository<Ipv6RangeInfo, String> {

    @Query(
            nativeQuery = true,
            value = "select *  from t_ipv6_range_info where " +
                    " :ip between hex(c_ip_start_num) and hex(c_ip_end_num)" +
                    " order by c_id asc limit 1"
    )
    Optional<Ipv6RangeInfo> findIpv6InfoByIpRange(@Param("ip") String ip);
}
